<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<{$config.weburl}>/script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<{$config.weburl}>/script/jquery.ui.js"></script>
<script type="text/javascript" src="<{$config.weburl}>/script/Validator.js"></script>
<div class="container">
<div class="oflow" style="height:480px">
<form name="form1" id="form1" action="module.php?m=product&s=order_opear.php" method="post">
<input name="id" type="hidden" id="id" value="<{$de.order_id}>">
<table class="table">
    <thead>
        <tr>
            <th class="partition" colspan="99">订单详情</th>
        </tr>
    </thead>
    <tbody>
    <tr>
        <td width="60">订单编号</td>
        <td colspan="3"><{$de.order_id}> <b class="org"><{$de.order_ship_status}></b></td>
    </tr>
    <tr>
        <td>下单时间</td>
        <td colspan="3"><{$de.create_time|date_format:"%Y-%m-%d&nbsp;%H:%M:%S"}></td>
    </tr>
    <tr>
        <td>配送方式：</td>
        <td width="200"><{$de.shipping_name}></td>
        <td width="60">配送费用:</td>
        <td><{$config.money}><{$de.freight}></td>
    </tr>
    
    <{if $de.status==2 and $de.pay_status==2}>
     <tr>
        <td>物流公司</td>
        <td colspan="3">
        <select name="shipping_express_id" id="shipping_express_id" dataType="Require" msg="请选择物流公司">
        <option value="">--请选择--</option>
         <{foreach item=item key=key from=$shipping_express}>
            <option value="<{$item.id}>_<{$item.company}>" express-sign="<{$item.sign}>" <{if $de.shipping_express_id==$item.id }>selected<{/if}>>
            <{$item.company}>
            </option>
        <{/foreach}>
        </select>
        <span>税费:&nbsp;<{$de.tax_price}>元<!-- <{if $de.tax_price<=$recommend_rate_price}>&nbsp;&nbsp;&nbsp;推荐快递:四川邮政小包<{/if}> --></span>
        </td>
    </tr>
    <tr>
        <td>物流单号</td>
        <td colspan="3"><input type="text" name="shipping_no" id="shipping_no" dataType="Require" msg="不能为空" class="w350" value="<{$de.shipping_no}>" /></td>
    </tr>
    <tr>
        <td>实际重量</td>
        <td colspan="3"><input type="text" name="shipping_weight" id="shipping_weight" dataType="Double" msg="格式不正确" class="w350" value="<{$de.shipping_weight}>" />&nbsp;&nbsp;kg</td>
    </tr>
    <tr>
        <td>实际运费</td>
        <td colspan="3"><input type="text" name="shipping_freight" id="shipping_freight" dataType="Double" msg="格式不正确" class="w350" value="<{$de.shipping_freight}>" /></td>
    </tr>
    <tr>
        <td>收货人</td>
        <td colspan="3"><input type="text" name="ship_name" class="w350" dataType="Require" msg="不能为空" value="<{$de.ship_name}>" /></td>
    </tr>
    <tr>
        <td>邮编</td>
        <td colspan="3">
        <input type="text" name="ship_zip" class="w350" dataType="Zip" msg="格式不正确" value="<{$de.ship_zip}>" />
        </td>
    </tr>
    <tr>
        <td>手机</td>
        <td colspan="3">
        <input type="text" name="ship_mobile" class="w350" dataType="Mobile" msg="格式不正确" value="<{$de.ship_mobile}>" />
        </td>
    </tr>
    <tr>
        <td>收货地址</td>
        <td colspan="3"><input type="text" name="ship_addr" class="w350" dataType="Require" msg="不能为空" value="<{$de.ship_addr}>" /></td>
    </tr>
    <{else}>
    <tr>
        <td>物流单号</td>
        <td colspan="3"><{$de.shipping_no}></td>
    </tr>
    <tr>
        <td>收货人</td>
        <td colspan="3"><{$de.ship_name}></td>
    </tr>
    <tr>
        <td>联系电话</td>
        <td colspan="3"><{$de.ship_mobile}> <{$de.ship_tel}></td>
    </tr>
    <tr>
        <td>收货地址</td>
        <td colspan="3"><{$de.ship_addr}></td>
    </tr>
    <{/if}>   
    </tbody>
</table>
<div class="dialog_button">
<{if $de.status==2}>
    <input id="edit" type="button" value="编辑">
    <input id="save" type="button" value="发货">
    <input name="act" type="hidden" id="action" value="ship"> 
    <input name="is_edit" type="hidden" id="is_edit" value="0"> 
<{else}>
    <input id="close" type="button" value="关闭">
<{/if}>  
</div>
</form>
<div id="error"></div> 
<script>
function $$(id) {
    return !id ? null : document.getElementById(id);
}
function ajaxpost(formid) {
    var ajaxframeid = 'ajaxframe';
    var ajaxframe = $$(ajaxframeid);
    if(!ajaxframe){
        var div = document.createElement('div');
        div.style.display = 'none';
        div.innerHTML = '<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '" loading="1"></iframe>';
        ajaxframe = $$(ajaxframeid);
        $$('append_parent').appendChild(div);
    }
    $$(formid).target = ajaxframeid;
    var valid = Validator.Validate($$(formid),3);
    if(!valid){
    	return;
    }
    $$(formid).submit();
    window.parent.main.document.location.reload();
    setTimeout("DialogManager.close('order')",500);
}
$("#save").click(function () {
    if($('#shipping_no').val()=='0'){
        $('#shipping_no').val('');
    }
    if($('#shipping_weight').val()=='0'){
        $('#shipping_weight').val('');
    }
    if($('#shipping_freight').val()=='0'){
        $('#shipping_freight').val('');
    }
    if(!($('#shipping_no').val())){
    	var express_sign = $('#shipping_express_id').find("option:selected").attr("express-sign");
	    if(express_sign=='sps' || express_sign=='emssc'){
	    	//获取可分配运单号数量
	    	var num = 0;
	    	$.get('<{$config.weburl}>/admin/module.php?m=product&s=order_opear.php&act=getExpressNoRestNum&expressId=19',function(data){
	    		num = data.num;
		    	if(!(num>0)){
		    		alert('无运单号可分配，请手动填写！');
		    		return false;
		    	}
	    	},'json');
	    	
	    	$('#shipping_no').val('自动分配');
	    }
    }
    ajaxpost("form1");
    return false;
});
$("#edit").click(function () {
	$("#is_edit").val('1');
	var express_sign = $('#shipping_express_id').find("option:selected").attr("express-sign");
	if(express_sign=='sps' || express_sign=='emssc'){
		if($('#shipping_no').val()==''){
			$('#shipping_no').val('0');
		}
		if($('#shipping_weight').val()==''){
            $('#shipping_weight').val('0');
        }
		if($('#shipping_freight').val()==''){
            $('#shipping_freight').val('0');
        }
	}
    ajaxpost("form1");
    return false;
});
$("#close").click(function () {
    window.parent.main.document.location.reload();
    DialogManager.close("order");
});
</script>
</form>
</div>
</div>